<%--
  Created by IntelliJ IDEA.
  User: 25131
  Date: 2021/10/18
  Time: 21:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>树懒商城收银台</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/ready_to_pay.css">

    <script src="${pageContext.request.contextPath}/res/jquery/jquery-3.5.1.min.js"></script>
</head>
<body>

<%
    String str = request.getParameter("newMyOrderId");
    int id = Integer.parseInt(str);
%>


<!--最上面的导航-->
<div class="shortcut-2014">
    <div class="w haha">
        <ul class="fr">

            <c:if test="${empty loginCustomer}">
                <li class="fore1 fore1zidingyi" id="ttbar-login">
                    <a href="${pageContext.request.contextPath}/customer/login.jsp" class="link-login">你好，请登录</a>
                    &nbsp;&nbsp;
                    <a href="" class="link-regist style-red">免费注册</a>
                </li>
            </c:if>

            <c:if test="${!empty loginCustomer}">
                <li class="fore1 fore1zidingyi" id="ttbar-login">
                    <span style="font-size: 12px">欢迎</span>
                    &nbsp;&nbsp;
                    <span style="color: red;">${loginCustomer.custNickname}</span>
                    &nbsp;&nbsp;
                    <span style="font-size: 12px">登录</span>
                    &nbsp;&nbsp;
                    <a href="${pageContext.request.contextPath}/cust/logout" class="link-regist style-red">退出</a>
                </li>
            </c:if>

            <%--<li class="fore1 fore1zidingyi" id="ttbar-login">
                <a href="" class="link-login">你好，请登录</a>
                &nbsp;&nbsp;
                <a href="" class="link-regist style-red">免费注册</a>
            </li>--%>
            <!--<li class="spacer"></li>-->
            <li class="fore2">
                <div class="dt">
                    <a href="${pageContext.request.contextPath}/myorder/${loginCustomer.custId}" target="_blank">我的订单</a>
                </div>
            </li>
        </ul>
    </div>
</div>


<div class="mod_conatiner">

    <!-- 最上面一行信息 -->
    <div class="dingbu">
        <div class="dingbu1">
            <div class="img-dignbu"></div>
            <img src="${pageContext.request.contextPath}/images/dingdanxaingqinglogo.png" style="height: 59px;margin-left: 300px;">

            <%-- 返回首页 --%>
            <a href="#none" style="position: relative;top: -25px;color: white;">树懒商城收银台</a>

            <div class="ziti">树懒商城感谢您的选择，祝您购物愉快！</div>
        </div>
    </div>

    <!-- 中间的支付宝返回信息 -->
    <%--<div class="info_first">

        <div class="xinshixinxi">

            <div class="jieguoxinashi">支付成功</div>

            <table>
                <tr>
                    <td>订单编号：</td>
                    <td class="xinxiha">${myOrderId}</td>
                    <!--                        <span >53425vsdafgsd</span>-->
                    <!--                        <input type="text" value="53425vsdafgsd" readonly>-->
                </tr>
                <!--<tr>
                    <td>53425vsdafgsd</td>
                </tr>-->

                <tr>
                    <td>支付宝单号：</td>
                    <td class="xinxiha">${trade_no}</td>
                </tr>
                <!--<tr>
                    <td>4325234623462</td>
                </tr>-->

                <tr>
                    <td>实付金额：</td>
                    <td class="xinxiha">${total_amount}</td>
                </tr>
                <!--<tr>
                    <td>4523.00</td>
                </tr>-->

                <tr>
                    <td>支付时间：</td>
                    <td class="xinxiha" style="width: auto;">${timestamp}</td>
                </tr>
                <!--<tr>
                    <td>2021:10:12 10:23:55</td>
                </tr>-->
            </table>

        </div>


    </div>--%>

    <%-- 中间信息 --%>
    <div class="info_first">

        <div>
            <div class="prder_info" style="width: 400px;border: 1px solid #fff;margin:auto;height: 200px;padding-top: 66px;">
                <%--<button onclick="btn()" class="checkout-submit" id="order-submit" style="margin-left: 650px;margin-top: 200px;">
&lt;%&ndash;                    <input type="text" name="<%=id %>" value="<%=id %>" class="myorderidzhifu"/>&ndash;%&gt;
&lt;%&ndash;                    提交订单&ndash;%&gt;
                    <form id="payForm" action="<%=request.getContextPath() %>/ali/pay" method="post">
                        <input type="text" name="<%=id %>" value="<%=id %>" class="myorderidzhifu" style="border: none;"> <br>
                        <input id="goPayBtn" type="submit" value="调用蚂蚁金服支付">
                    </form>

                    <!-- 直接在里面放一个 form 表单 跳转到 支付宝沙箱支付就可以了 -->
                    &lt;%&ndash;'<form id="payForm" action="<%=request.getContextPath() %>/ali/pay" method="post">\n' +
                    '    <input type="btn" name="newMyOrderId" id="newMyOrderId" />\n' +
                    '    <input id="goPayBtn" type="submit" style="display: none;" value="调用蚂蚁金服支付">\n' +
                    '</form>')&ndash;%&gt;

                    <b></b>
                </button>
                <div id="hahahaha" class="heiheihei">

                </div>--%>

                <form id="payForm" action="<%=request.getContextPath() %>/ali/pay" method="post" style="width: 300px;height: 180px;background: red;padding: 3px 3px 3px;">
                    <span style="height: 20px;width: 100px;display: inline-block;size: 14px;">订单id：</span>
                    <input type="text" name="newMyOrderId" value="<%=id %>" style="height: 30px;size: 15px;" readonly> <br>
                    <input id="goPayBtn" type="submit" value="调用蚂蚁金服支付"> <br>
                </form>

            </div>
        </div>

    </div>


    <!--下方提示信息-->
    <div id="cmsfooter">
        <div id="service-2017">

            <!-- 多快好省 -->
            <div class="w hhzidingyi">
                <ol class="slogen">
                    <li class="item fore1">
                        <i>多</i>
                        品类齐全，轻松购物
                    </li>
                    <li class="item fore2">
                        <i>多</i>
                        多仓发货，极速配送
                    </li>
                    <li class="item fore3">
                        <i>好</i>
                        正品行货，精致服务
                    </li>
                    <li class="item fore4">
                        <i>省</i>
                        天天低价，畅选无忧
                    </li>
                </ol>
            </div>

            <!--下面的信息-->
            <div class="shulan-help">
                <div class="w hhzidingyi">
                    <div class="tishixinxi">
                        <span class="zititishixinxi">欢迎使用树懒商城，为您提供高质量的服务，是我们商城最高的追求！</span>
                    </div>
                </div>
            </div>

        </div>
    </div>

</div>


<script>

    // 点击提交按钮，提交
    function btn(){
        // 拿到订单id的值
        var newMyOrderId = document.querySelector(".myorderidzhifu").value;
        console.log(newMyOrderId);

        // 点击提交订单按钮之后，跳转到controller层进行监听队列
        $.ajax({
            url:"${pageContext.request.contextPath}/listen",
            data:{
                "newMyOrderId":newMyOrderId
            },
            method:'post',
            async:false,
            dataType:"json",
            success:function (result){
                console.log("跳转支付宝沙箱支付");
                console.log(result);

                $('#hahahaha').after(
                    '<form id="payForm" action="<%=request.getContextPath() %>/ali/pay" method="post">\n' +
                    '    <input type="btn" name="newMyOrderId" id="newMyOrderId" />\n' +
                    '    <input id="goPayBtn" type="submit" style="display: none;" value="调用蚂蚁金服支付">\n' +
                    '</form>')
                $("#newMyOrderId").val(newMyOrderId);
                // $("#goPayBtn").submit();
                $("#goPayBtn").click();

            }
        })


    }

</script>

</body>
</html>